<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2017/10/30 0030
 * Time: 上午 10:41
 */

namespace  App\Http\Models;


use App\Http\Requests\Request;

class UploadModel
{

    function uploadimage(Request $request ){
        $file=$request->file('source');    //文件上传的name是source
        //判断文件是否上传成功
        if ($file->isValid()) {
            $originaName=$file->getClientOriginalName();    //取原文件名
            $ext=$file->getClientOriginalExtension();        //取文件的扩展名
            $type=$file->getClientMimeType();                //文件的类型MimeType
            $realPath=$file->getRealPath();                    //临时的绝对路径
            //用时间加uniqid作为上传上来的文件名,Y-m-d-H-i-s就这样,如果Y-m-d H-i-s会在下面put报错的
            $filename=date('Y-m-d-H-i-s').'-'.uniqid().'.'.$ext;
            //use Illuminate\Support\Facades\Storage;
            //调用uploads,之前在config/filesystems.php设置的
            $bool=Storage::disk('uploads')->put($filename,file_get_contents($realPath));//成功true
        }
    }

}